package com.dankegongyu.lib.ui.widget.popup;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.dankegongyu.lib.ui.widget.DKUIWrapContentListView;

public class DKUIPopups {

    public static DKUIPopup popup(Context context) {
        return new DKUIPopup(context,
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    public static DKUIPopup popup(Context context, int width) {
        return new DKUIPopup(context,
                width,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    public static DKUIPopup popup(Context context, int width, int height) {
        return new DKUIPopup(context, width, height);
    }

    /**
     * show a list with popup
     *
     * @param context             activity context
     * @param width               the with for the popup content
     * @param maxHeight           the max height of popup, it is scrollable if the content is higher then maxHeight
     * @param adapter             the adapter for the list view
     * @param onItemClickListener the onItemClickListener for list item view
     * @return DKUIPopup
     */
    public static DKUIPopup listPopup(Context context, int width, int maxHeight,
                                      BaseAdapter adapter,
                                      AdapterView.OnItemClickListener onItemClickListener) {
        ListView listView = new DKUIWrapContentListView(context, maxHeight);
        listView.setAdapter(adapter);
        listView.setVerticalScrollBarEnabled(false);
        listView.setOnItemClickListener(onItemClickListener);
        listView.setDivider(null);
        return popup(context, width).view(listView);
    }

//    public static QMUIFullScreenPopup fullScreenPopup(Context context) {
//        return new QMUIFullScreenPopup(context);
//    }
//
//    public static QMUIQuickAction quickAction(Context context, int actionWidth, int actionHeight) {
//        return new QMUIQuickAction(context, ViewGroup.LayoutParams.WRAP_CONTENT, actionHeight)
//                .actionWidth(actionWidth)
//                .actionHeight(actionHeight);
//    }
}
